package com.javasm.common.util;

import com.javasm.service.redisDictService.SysDictService;
import org.springframework.context.ApplicationContext;

import java.util.LinkedHashMap;
import java.util.Map;

//RedisDistUtil:Spring容器不允许普通Pojo调用Service,所以采用以下方式手动通过Spring容器去加载Bean.
public class RedisDistUtil {

    private static final ApplicationContext context = SpringUtil.getApplicationContext();
    private static final SysDictService sysDictService =context.getBean(SysDictService.class);
    /**
     * 转化码值
     * @param distname
     * @param value
     * @return
     * @throws Exception
     */
    public static String transformStr(String distname, int value)  {

        return sysDictService.transformStr(distname,value);
    }

    /**
     * 本地内存版本
     * @param distname 字典字段名称
     * @param value 对应的值
     * @return 对应的中文值
     */
    public static String ramTransformStr(String distname, int value)  {
        return sysDictService.ramTransformStr(distname,value);
    }


    public static Map<String, LinkedHashMap<Integer, String>> transformTypeList(String distname)  {
        return sysDictService.transformTypeList(distname);
    }

    public static Map<String, LinkedHashMap<Integer, String>> transformTypeList()  {
        return sysDictService.transformTypeList();
    }
}
